package com.example.receiver;

import java.util.ArrayList;

import com.google.android.gms.maps.GoogleMap;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;

public class MainActivity extends Activity {

	GoogleMap myMap;
	Button btninterre;
	Button btnstopreinternet;
	Intent bgserviceinternet;
	public static Boolean statusthread;
	BroadcastReceiver mReceiver;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		intialwidget();
		
		/* IntentFilter filter = new IntentFilter();
         filter.addAction("action");
         filter.addAction("anotherAction");
         mReceiver = new ReceiverSMS();
         registerReceiver(mReceiver, filter);*/
		
	
	        // receive list incoming messages
	        ArrayList<SmsInfo> listSms = getIntent().getParcelableArrayListExtra("ListSMS");
	        // check condition
	        if(listSms != null && listSms.size() > 0) {
	            // set dat to list
	          Intent gotonext = new Intent(MainActivity.this,ShowSMS.class);
	          gotonext.putParcelableArrayListExtra("listItem", listSms);
	          startActivity(gotonext);
	        }
	        
		btninterre.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
			
			 	// optional: send Extra to IntentService
				// intent.putExtra("name", "value");
				BlackgroupService.isLooping = true;
				bgserviceinternet = new Intent(MainActivity.this,BlackgroupService.class);
				Log.v("Apiwa Looping", "Looping = " + BlackgroupService.isLooping);
				startService(bgserviceinternet);
			}
		});
		
		
		btnstopreinternet .setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				statusthread = false;
				stopService(bgserviceinternet);	
				
			}
		});
		
		
		
		

	}

	private void intialwidget() {
		// TODO Auto-generated method stub
		btninterre = (Button) findViewById(R.id.StartReInternet);
		btnstopreinternet = (Button) findViewById(R.id.StopReInternet);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
